#include "zone.h"

Zone::Zone(QObject *parent) :
    QObject(parent), p_trionId(0), p_level(0)
{
}

Zone::Zone(const Zone &z) :
  QObject(z.parent())
{
  p_name = z.p_name;
  p_trionId = z.p_trionId;
  p_eventName = z.p_eventName;
  p_eventTime = z.p_eventTime;
  p_level = z.p_level;
}

Zone& Zone::operator=(const Zone &z)
{
  p_name = z.p_name;
  p_trionId = z.p_trionId;
  p_eventName = z.p_eventName;
  p_eventTime = z.p_eventTime;
  p_level = z.p_level;
  return *this;
}

QString Zone::name() const
{
  return p_name;
}

int Zone::trionId() const
{
  return p_trionId;
}

QString Zone::eventName() const
{
  return p_eventName;
}

QTime Zone::eventTime() const
{
  return p_eventTime;
}

int Zone::level() const
{
    return p_level;
}

void Zone::setTrionId(int id)
{
  p_trionId = id;
  QMap<int, QPair<QString, int> > m = zoneList();
  if(m.contains(id))
  {
      p_name = m.value(id).first;
      p_level = m.value(id).second;
  }
  else
  {
      p_name = tr("Unknown zone");
      p_level = 0;
  }
}

void Zone::setEventName(const QString &str)
{
  p_eventName = str;
}

void Zone::setEventTime(const QTime &time)
{
  p_eventTime = time;
}

bool Zone::operator<(const Zone &z) const
{
  return p_level < z.p_level;
}

QMap<int, QPair<QString, int> > Zone::zoneList()
{
    QMap<int, QPair<QString, int> > m;
    m.insert(6, QPair<QString, int>(tr("Shimmersand"), 45));
    m.insert(26, QPair<QString, int>(tr("Stillmore"), 45));
    m.insert(12, QPair<QString, int>(tr("Silverwood"), 10));
    m.insert(22, QPair<QString, int>(tr("Iron Pine Peak"), 45));
    m.insert(19, QPair<QString, int>(tr("Freemarch"), 10));
    m.insert(1992854106, QPair<QString, int>(tr("Ember Isle"), 50));
    m.insert(20, QPair<QString, int>(tr("Scarwood Reach"), 30));
    m.insert(336995470, QPair<QString, int>(tr("Droughtlands"), 40));
    m.insert(26580443, QPair<QString, int>(tr("Scarlet Gorge"), 25));
    m.insert(27, QPair<QString, int>(tr("Gloamwood"), 20));
    m.insert(1481781477, QPair<QString, int>(tr("Stonefield"), 20));
    m.insert(24, QPair<QString, int>(tr("Moonshade highlands"), 35));
    m.insert(479431687, QPair<QString, int>(tr("Kingdom of Pelladane"), 51));
    m.insert(1770829751, QPair<QString, int>(tr("Cape Jule"), 51));
    m.insert(1494372221, QPair<QString, int>(tr("Seratos"), 52));
    m.insert(1300766935, QPair<QString, int>(tr("Kingsward"), 56));
    m.insert(1213399942, QPair<QString, int>(tr("Eastern Holdings"), 54));
    m.insert(1967477725, QPair<QString, int>(tr("City Core"), 52));
    m.insert(790513416, QPair<QString, int>(tr("Ashora"), 58));
    m.insert(798793247, QPair<QString, int>(tr("Steppes of infinity"), 58));
    m.insert(1446819710, QPair<QString, int>(tr("Ardent domain"), 55));
    m.insert(956914599, QPair<QString, int>(tr("Morban"), 56));
    return m;
}

bool Zone::operator==(const Zone& z) const
{
  return p_trionId == z.p_trionId;
}
